package main

import (
	"fmt"
)

func maxProduct(nums []int) int {
	start := 0
	end := 0
	maxValue := nums[0] //默认当前数组的第一个元素为最大乘积值

	if len(nums) == 1 {
		return nums[0]
	}
	for i := 0; i < len(nums); i++ {
		num := 1 //当前子数组的乘积
		for j := i; j < len(nums); j++ {
			num *= nums[j]
			if num > maxValue {
				maxValue = num
				start = i
				end = j
			}
		}
	}
	fmt.Println("子数组开始坐标：", start, "子数组结束坐标：", end)
	return maxValue
}

func main() {
	nums := []int{2, 0}
	fmt.Println(maxProduct(nums))
	nums1 := []int{2, 3, -2, 4}
	fmt.Println(maxProduct(nums1))
}
